package com.community.controller;


import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.community.entity.LampLog;
import com.community.entity.User;
import com.community.service.LampLogService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.Date;
import java.util.List;

/**
 * (LampLog)表控制层
 *
 * @author makejava
 * @since 2021-12-06 10:34:41
 */
@Controller
@RequestMapping("lampLog2")
public class LampLogController2 extends ApiController {

    @RequestMapping("lamploglist")
    public String tolist() {
        return "lamp_loglist";
    }

    /**
     * 分页查询所有数据
     *
     * @return 所有数据
     */
    @GetMapping("list")
    @ResponseBody
    public R selectAll() throws IOException {
        String urlPath = "https://www.vip3070.com/Public_Aspx/History_list.aspx?id=44608&io=IO02";
        String cookie = "ASP.NET_SessionId=2ok5dmnc5tmzltjst4mvqe3p; Member_login=name=173c42006f4&openid=9AA3C0C072F9961E3FB06BD689F83B88";
        URL url = new URL(urlPath);
        URLConnection conn = url.openConnection();
        conn.setRequestProperty("Cookie", cookie);
        conn.setDoInput(true);
        BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        StringBuilder sb = new StringBuilder();
        String line = null;
        while ((line = br.readLine()) != null) {
            sb.append(line);
        }
        System.out.println("请求响应结果：" + sb);
        return this.success(sb);
    }
}

